package com.fei.yuan.myapplication.utils;

import com.fei.yuan.myapplication.ResourceTable;
import ohos.app.Context;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @since 2021-07-20
 */
public class DateUtils {

    /**
     * 获取当前日期
     *
     * @param format format
     * @return 日期
     */
    public static String getCurrentDate(String format) {
        DateFormat dateFormat = new SimpleDateFormat(format);
        Date date = new Date();
        String formatDate = dateFormat.format(date);
        return formatDate;
    }

    //获取星期
    public static String getWeek(Context context, int week) {

        int stringId;
        switch (week) {
            case 1:
                stringId = ResourceTable.String_SUNDAY;
                break;
            case 2:
                stringId = ResourceTable.String_MONDAY;
                break;
            case 3:
                stringId = ResourceTable.String_TUESDAY;
                break;
            case 4:
                stringId = ResourceTable.String_WEDNESDAY;
                break;
            case 5:
                stringId = ResourceTable.String_THURSDAY;
                break;
            case 6:
                stringId = ResourceTable.String_FRIDAY;
                break;
            case 7:
                stringId = ResourceTable.String_SATURDAY;
                break;
            default:
                stringId = ResourceTable.String_SUNDAY;
                break;
        }
        return context.getString(stringId);
    }
}
